﻿Imports System.Data.OleDb

Public Class ItemsDAO

    Public Function Items_RefreshQuantity() As Boolean
        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Items_RefreshQuantity", Nothing)
    End Function

    Public Function Items_List() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_Item_List", Nothing)
    End Function

    Public Function Item_Report_Select() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_Item_Report_Select", Nothing)
    End Function

    Public Function Item_Select(ByVal ItemID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@ItemID", ItemID)
        para(0).OleDbType = OleDbType.Integer

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_Item_Select", para)
    End Function

    Public Function Item_Insert(ByVal ItemCode As String, _
                                ByVal CatelogyID As Integer, _
                                ByVal Name As String, _
                                ByVal Description As String, _
                                ByVal ModelNumber As String, _
                                ByVal ManufacturerID As Integer, _
                                ByVal PrimaryVendorID As Integer, _
                                ByVal SecondaryVendorID As Integer, _
                                ByVal UnitOfMeasureID As Integer, _
                                ByVal CreatedBy As String, _
                                ByVal CreatedOn As Date, _
                                ByVal ModifiedBy As String, _
                                ByVal ModifiedOn As Date, _
                                ByVal StatusInd As Boolean, _
                                ByVal Amperage As String, _
                                ByVal BuyPrice As Decimal, _
                                ByVal SellPrice As Decimal, _
                                ByVal Quantity As Integer, _
                                ByVal Notes As String, _
                                ByVal ServiceFlag As Boolean) As Boolean
        Dim para(19) As OleDbParameter
        para(0) = New OleDbParameter("@ItemCode", ItemCode)
        para(0).OleDbType = OleDbType.VarWChar

        para(1) = New OleDbParameter("@CatelogyID", CatelogyID)
        para(1).OleDbType = OleDbType.Integer

        para(2) = New OleDbParameter("@Name", Name)
        para(2).OleDbType = OleDbType.VarWChar

        para(3) = New OleDbParameter("@Description", Description)
        para(3).OleDbType = OleDbType.VarWChar

        para(4) = New OleDbParameter("@ModelNumber", ModelNumber)
        para(4).OleDbType = OleDbType.VarWChar

        para(5) = New OleDbParameter("@ManufacturerID", ManufacturerID)
        para(5).OleDbType = OleDbType.Integer

        para(6) = New OleDbParameter("@PrimaryVendorID", PrimaryVendorID)
        para(6).OleDbType = OleDbType.Integer

        para(7) = New OleDbParameter("@SecondaryVendorID", SecondaryVendorID)
        para(7).OleDbType = OleDbType.Integer

        para(8) = New OleDbParameter("@UnitOfMeasureID", UnitOfMeasureID)
        para(8).OleDbType = OleDbType.Integer

        para(9) = New OleDbParameter("@CreatedBy", CreatedBy)
        para(9).OleDbType = OleDbType.VarWChar

        para(10) = New OleDbParameter("@CreatedOn", CreatedOn)
        para(10).OleDbType = OleDbType.Date

        para(11) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(11).OleDbType = OleDbType.VarWChar

        para(12) = New OleDbParameter("@ModifiedOn", ModifiedOn)
        para(12).OleDbType = OleDbType.Date

        para(13) = New OleDbParameter("@StatusInd", StatusInd)
        para(13).OleDbType = OleDbType.Boolean

        para(14) = New OleDbParameter("@Amperage", Amperage)
        para(14).OleDbType = OleDbType.VarWChar

        para(15) = New OleDbParameter("@BuyPrice", BuyPrice)
        para(15).OleDbType = OleDbType.Currency

        para(16) = New OleDbParameter("@SellPrice", SellPrice)
        para(16).OleDbType = OleDbType.Currency

        para(17) = New OleDbParameter("@Quantity", Quantity)
        para(17).OleDbType = OleDbType.Integer

        para(18) = New OleDbParameter("@Notes", Notes)
        para(18).OleDbType = OleDbType.VarWChar

        para(19) = New OleDbParameter("@ServiceFlag", ServiceFlag)
        para(19).OleDbType = OleDbType.Boolean

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Item_Insert", para)
    End Function

    Public Function Item_Update(ByVal ItemID As Integer, _
                                ByVal ItemCode As String, _
                                ByVal CatelogyID As Integer, _
                                ByVal Name As String, _
                                ByVal Description As String, _
                                ByVal ModelNumber As String, _
                                ByVal ManufacturerID As Integer, _
                                ByVal PrimaryVendorID As Integer, _
                                ByVal SecondaryVendorID As Integer, _
                                ByVal UnitOfMeasureID As Integer, _
                                ByVal CreatedBy As String, _
                                ByVal CreatedOn As Date, _
                                ByVal ModifiedBy As String, _
                                ByVal ModifiedOn As Date, _
                                ByVal StatusInd As Boolean, _
                                ByVal Amperage As String, _
                                ByVal BuyPrice As Decimal, _
                                ByVal SellPrice As Decimal, _
                                ByVal Quantity As Integer, _
                                ByVal Notes As String, _
                                ByVal ServiceFlag As Boolean) As Boolean
        Dim para(20) As OleDbParameter

        para(0) = New OleDbParameter("@ItemID", ItemID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@ItemCode", ItemCode)
        para(1).OleDbType = OleDbType.VarWChar

        para(2) = New OleDbParameter("@CatelogyID", CatelogyID)
        para(2).OleDbType = OleDbType.Integer

        para(3) = New OleDbParameter("@Name", Name)
        para(3).OleDbType = OleDbType.VarWChar

        para(4) = New OleDbParameter("@Description", Description)
        para(4).OleDbType = OleDbType.VarWChar

        para(5) = New OleDbParameter("@ModelNumber", ModelNumber)
        para(5).OleDbType = OleDbType.VarWChar

        para(6) = New OleDbParameter("@ManufacturerID", ManufacturerID)
        para(6).OleDbType = OleDbType.Integer

        para(7) = New OleDbParameter("@PrimaryVendorID", PrimaryVendorID)
        para(7).OleDbType = OleDbType.Integer

        para(8) = New OleDbParameter("@SecondaryVendorID", SecondaryVendorID)
        para(8).OleDbType = OleDbType.Integer

        para(9) = New OleDbParameter("@UnitOfMeasureID", UnitOfMeasureID)
        para(9).OleDbType = OleDbType.Integer

        para(10) = New OleDbParameter("@CreatedBy", CreatedBy)
        para(10).OleDbType = OleDbType.VarWChar

        para(11) = New OleDbParameter("@CreatedOn", CreatedOn)
        para(11).OleDbType = OleDbType.Date

        para(12) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(12).OleDbType = OleDbType.VarWChar

        para(13) = New OleDbParameter("@ModifiedOn", ModifiedOn)
        para(13).OleDbType = OleDbType.Date

        para(14) = New OleDbParameter("@StatusInd", StatusInd)
        para(14).OleDbType = OleDbType.Boolean

        para(15) = New OleDbParameter("@Amperage", Amperage)
        para(15).OleDbType = OleDbType.VarWChar

        para(16) = New OleDbParameter("@BuyPrice", BuyPrice)
        para(16).OleDbType = OleDbType.Currency

        para(17) = New OleDbParameter("@SellPrice", SellPrice)
        para(17).OleDbType = OleDbType.Currency

        para(18) = New OleDbParameter("@Quantity", Quantity)
        para(18).OleDbType = OleDbType.Integer

        para(19) = New OleDbParameter("@Notes", Notes)
        para(19).OleDbType = OleDbType.VarWChar

        para(19) = New OleDbParameter("@ServiceFlag", ServiceFlag)
        para(19).OleDbType = OleDbType.Boolean

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Item_Update", para)
    End Function

    Public Function Item_Delete(ByVal ItemID As Integer) As Boolean
        Dim para(1) As OleDbParameter
        para(0) = New OleDbParameter("@ItemID", ItemID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@Success", OleDbType.Boolean)
        para(1).Direction = ParameterDirection.Output

        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_Item_Delete", para)
        Return para(1).Value

    End Function

End Class
